package com.ruoyi.system.controller;

import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysUserInvestor;
import com.ruoyi.system.service.ISysUserInvestorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投资人信息Controller
 * 
 * @author paul
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/investor")
public class SysUserInvestorController extends BaseController
{
    @Autowired
    private ISysUserInvestorService sysUserInvestorService;

    /**
     * 查询投资人信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserInvestor sysUserInvestor)
    {
        startPage();
        List<SysUserInvestor> list = sysUserInvestorService.selectSysUserInvestorList(sysUserInvestor);
        return getDataTable(list);
    }

    /**
     * 导出投资人信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:export')")
    @Log(title = "投资人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserInvestor sysUserInvestor)
    {
        List<SysUserInvestor> list = sysUserInvestorService.selectSysUserInvestorList(sysUserInvestor);
        ExcelUtil<SysUserInvestor> util = new ExcelUtil<SysUserInvestor>(SysUserInvestor.class);
        util.exportExcel(response, list, "投资人信息数据");
    }

    /**
     * 获取投资人信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysUserInvestorService.selectSysUserInvestorById(id));
    }

    /**
     * 新增投资人信息
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:add')")
    @Log(title = "投资人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserInvestor sysUserInvestor)
    {
        return toAjax(sysUserInvestorService.insertSysUserInvestor(sysUserInvestor));
    }

    /**
     * 修改投资人信息
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:edit')")
    @Log(title = "投资人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserInvestor sysUserInvestor)
    {
        return toAjax(sysUserInvestorService.updateSysUserInvestor(sysUserInvestor));
    }

    /**
     * 删除投资人信息
     */
//    @PreAuthorize("@ss.hasPermi('system:investor:remove')")
    @Log(title = "投资人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysUserInvestorService.deleteSysUserInvestorByIds(ids));
    }
}
